typedef struct
{
    int active_queue[101];
    int active_front;
    int active_tail;

    int invalid_queue[101];
    int invalid_front;
    int invalid_tail;
} MyStack;


MyStack* myStackCreate()
{
    MyStack* newStack = (MyStack *)malloc(sizeof(MyStack));
    newStack->invalid_front=newStack->invalid_tail=0;
    newStack->active_front=newStack->active_tail=0;
    return newStack;
}

bool myStackEmpty(MyStack* obj)
{
    if(obj->active_front == obj->active_tail)
        return true;
    else
        return false;
}

void myStackPush(MyStack* obj, int x)
{
    if(myStackEmpty(obj))
        obj->active_queue[obj->active_tail++] = x;
    else
    {
        obj->invalid_front = 0;
        obj->invalid_tail = 0;
        while(obj->active_front < obj->active_tail)
        {
            obj->invalid_queue[obj->invalid_tail++] = obj->active_queue[obj->active_front++];
        }
        obj->active_front = 0;
        obj->active_tail = 0;
        obj->active_queue[obj->active_tail++] = x;
        while(obj->invalid_front < obj->invalid_tail)
            obj->active_queue[obj->active_tail++] = obj->invalid_queue[obj->invalid_front++];
        obj->invalid_front = 0;
        obj->invalid_tail = 0;
    }
}

int myStackPop(MyStack* obj)
{
    int num = obj->active_queue[obj->active_front++];
    if(obj->active_front == obj->active_tail)
    {
        obj->active_front=0;
        obj->active_tail=0;
    }
    return num;
}

int myStackTop(MyStack* obj)
{
    return obj->active_queue[obj->active_front];
}

void myStackFree(MyStack* obj)
{
    free(obj);
}

/**
 * Your MyStack struct will be instantiated and called as such:
 * MyStack* obj = myStackCreate();
 * myStackPush(obj, x);
 
 * int param_2 = myStackPop(obj);
 
 * int param_3 = myStackTop(obj);
 
 * bool param_4 = myStackEmpty(obj);
 
 * myStackFree(obj);
*/